package com.hns.can.safety.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hns.can.common.aop.orgTree.LeftOrgAnnotation;
import com.hns.can.common.aop.sedate.SedateAnnotation;
import com.hns.can.common.constants.GlobalConst;
import com.hns.can.common.formula.FillCodeDscValue;
import com.hns.can.common.formula.FillParamsVo;
import com.hns.can.safety.entity.CommCarSpdingEntity;
import com.hns.can.safety.vo.OverspeedMonitorParamVo;
import com.hns.can.safety.vo.OverspeedStatisticsParamVo;
import com.hns.can.safety.vo.SpedReportSummaryVo;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;
import com.hns.tool.pub.SearchConditionVo;

/**
 * 超速统计业务类
 * @author:lan
 * @email:763836737@qq.com
 * @version Revision 2.0.0
 */
@Service
public class OverspeedService extends CommonService {
    
    @Autowired
    private FillCodeDscValue codeDscValue;
    
    /**
     * 获得超速统计的信息
     * @param conditionVo
     * @return
     * @throws Exception
     * @author:lan
     * @email:763836737@qq.com
     */
    @LeftOrgAnnotation()
    @SedateAnnotation()
    @Transactional
    public Pagination searchOverspeedStatisticsData(OverspeedStatisticsParamVo conditionVo) throws Exception {
        Pagination page = this.myBatisPage("overspeed.searchOverspeedStatisticsDataCnt", "overspeed.searchOverspeedStatisticsData", conditionVo,CommCarSpdingEntity.class);
        Map<String,String> map = new HashMap<String,String>();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo1 = new FillParamsVo("lineId", map);
        map = new HashMap<String,String>();
        map.put("organName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo2 = new FillParamsVo("organId", map);
        codeDscValue.fillInfoValue(page.getData(),new String[]{ GlobalConst.CACHE_KEY_BASE_LINE_INFO,GlobalConst.CACHE_KEY_BASE_ORGAN},vo1,vo2);
        return page;
    }
    
    /**
     * 获得超速统计的信息
     * @param conditionVo
     * @return
     * @throws Exception
     * @author:lan
     * @email:763836737@qq.com
     */
    @SuppressWarnings("unchecked")
    @LeftOrgAnnotation()
    @SedateAnnotation()
    @Transactional
    public List<SpedReportSummaryVo> searchOverspeedStatisticsList(OverspeedStatisticsParamVo conditionVo) throws Exception {
        List<SpedReportSummaryVo> list = PubUtil.convertListMapToObject(sqlMapDao.selectList("overspeed.searchOverspeedStatisticsData", conditionVo), SpedReportSummaryVo.class);
        Map<String,String> map = new HashMap<String,String>();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo1 = new FillParamsVo("lineId", map);
        map = new HashMap<String,String>();
        map.put("organName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo2 = new FillParamsVo("organId", map);
        codeDscValue.fillInfoValue(list,new String[]{ GlobalConst.CACHE_KEY_BASE_LINE_INFO,GlobalConst.CACHE_KEY_BASE_ORGAN},vo1,vo2);
        return list;
    }
    /**
     * 获取超速信息的page对象
     * @param conditionVo
     * @return
     * @throws Exception
     * @author:lan
     * @email:763836737@qq.com
     */
    @LeftOrgAnnotation()
    @SedateAnnotation()
    @Transactional
    public Pagination searchOverspeedPage(SearchConditionVo conditionVo) throws Exception {
        Pagination page = this.myBatisPage("overspeed.getOverspeedCnt", "overspeed.getOverspeedList", conditionVo,CommCarSpdingEntity.class);
        Map<String,String> map = new HashMap<String,String>();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo1 = new FillParamsVo("lineId", map);
        map = new HashMap<String,String>();
        map.put("organName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo2 = new FillParamsVo("organId", map);
        map = new HashMap<String,String>();
        map.put("licPltNo", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo3 = new FillParamsVo("carId", map);
        map = new HashMap<String,String>();
        map.put("drvName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo4 = new FillParamsVo("drvId", map);
        codeDscValue.fillInfoValue(page.getData(),new String[]{ GlobalConst.CACHE_KEY_BASE_LINE_INFO,GlobalConst.CACHE_KEY_BASE_ORGAN,GlobalConst.CACHE_KEY_BASE_DRV_INFO,GlobalConst.CACHE_KEY_BASE_CAR_INFO},vo1,vo2,vo3,vo4);
        return page;
    }

    /**
     * 获取超速的List对象
     * @param conditionVo
     * @return
     * @throws Exception
     * @author:lan
     * @email:763836737@qq.com
     */
    @SuppressWarnings({"unchecked", "rawtypes" })
    @LeftOrgAnnotation()
    @SedateAnnotation()
    @Transactional
    public List<CommCarSpdingEntity> getOverspeedList(OverspeedMonitorParamVo conditionVo) throws Exception {
        List list = PubUtil.convertListMapToObject( this.sqlMapDao.selectList("overspeed.getOverspeedList", conditionVo), CommCarSpdingEntity.class);
        Map<String,String> mapTmp = new HashMap<String,String>();
        mapTmp.put("spdingSeverity", "PARA0100");
        codeDscValue.fillCodeDscValue(list, mapTmp);
        Map<String,String> map = new HashMap<String,String>();
        map.put("lineName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo1 = new FillParamsVo("lineId", map);
        map = new HashMap<String,String>();
        map.put("organName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo2 = new FillParamsVo("organId", map);
        map = new HashMap<String,String>();
        map.put("licPltNo", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo3 = new FillParamsVo("carId", map);
        map = new HashMap<String,String>();
        map.put("drvName", GlobalConst.DEFAULT_CACHE_VALUE);
        FillParamsVo vo4 = new FillParamsVo("drvId", map);
        codeDscValue.fillInfoValue(list,new String[]{ GlobalConst.CACHE_KEY_BASE_LINE_INFO,GlobalConst.CACHE_KEY_BASE_ORGAN,GlobalConst.CACHE_KEY_BASE_DRV_INFO,GlobalConst.CACHE_KEY_BASE_CAR_INFO},vo1,vo2,vo3,vo4);
        return list;
    }
    
}
